<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        #box div{
            float: left;
            width: 100px;
            height: 100px;
            background: red;
            margin: 10px;
        }
    </style>
</head>
<body>
<div id="box"></div> 
<script>
{
    let box = document.querySelector("#box");
    // console.time(1);
    // let inner = "";
    // for(let i = 0; i < 1000; i++){
    //     inner += `<div>${i}</div>`;
    // }
    // box.innerHTML = inner;
    // console.timeEnd(1);
    console.time(1);
    let fragment = document.createDocumentFragment();
    for(let i = 0; i < 1000; i++){
        let div = document.createElement("div");
        div.innerHTML = i;
        fragment.appendChild(div);
    }
    box.appendChild(fragment);
    console.timeEnd(1);
}
</script>   
</body>
</html>